<!--
 * @Author: your name
 * @Date: 2021-08-06 09:37:38
 * @LastEditTime: 2021-08-06 11:55:34
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vuestudy\vue\16-常用开源Vue库\AtDesignVue.html
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <link rel="stylesheet" href="../15-组件/css/search.css" />
    <script src="../15-组件/components/search.js"></script>
  </head>
  <style>
    #app {
      float: left;
    }
  </style>
  <body>
    <div id="app">
      <mysearch :url="url" @transtext="getchildText"></mysearch>
      <h2>搜索的内容是：{{text}}</h2>
      <hr />
      <!-- 第一种写法 -->
      <mysearch
        :url="url"
        placeholder="请输入商品名称"
        @transtext="goodsname=$event"
      ></mysearch>
      <!-- 第二种写法 -->
      <mysearch
        :url="url"
        placeholder="请输入商品名称"
        @transtext="getGoodsName"
      ></mysearch>
      <h2>商品名称是：{{goodsname}}</h2>
      <hr />
    </div>
    <script>
      new Vue({
        el: "#app",
        data() {
          return {
            url: ["../16-父子组件参数互相调用/img/search.png"],
            text: "",
            goodsname: "",
          };
        },
        methods: {
          getchildText(e) {
            this.text = e;
          },
          getGoodsName(e) {
            this.goodsname = e;
          },
        },
      });
    </script>
  </body>
</html>
